[feat] Enable full configuration of code and hook workflows and their schemas#4711
[feat] Enable full configuration of code and hook workflows and their schemas#4711junaway wants to merge 8 commits into
code and hook workflows and their schemas#4711Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR expands the workflow entity data model from a ChangesWorkflow Full Data Expansion
Custom Hook Remote Forwarding
Sequence Diagram(s)sequenceDiagram
participant User
participant PlaygroundConfigSection
participant configUpdateRouterAtom
participant workflowMolecule
participant snapshotAdapter
participant commitApi
User->>PlaygroundConfigSection: edit code script or hook URL/headers
PlaygroundConfigSection->>configUpdateRouterAtom: dispatch {__siblingData: {script|url|headers}}
configUpdateRouterAtom->>workflowMolecule: write raw sibling data fields
User->>PlaygroundConfigSection: change runtime via dropdown
PlaygroundConfigSection->>configUpdateRouterAtom: dispatch {__siblingData: {runtime}}
configUpdateRouterAtom->>workflowMolecule: update runtime field
workflowMolecule->>snapshotAdapter: buildDraftPatch(currentData, serverBaseline)
snapshotAdapter->>snapshotAdapter: shallow diff full data object
snapshotAdapter-->>workflowMolecule: patch record (headers/script/runtime/parameters)
User->>PlaygroundConfigSection: commit revision
PlaygroundConfigSection->>commitApi: commitWorkflowRevisionApi({uri, url, headers, script, runtime, parameters, schemas})
sequenceDiagram
participant Decorator as workflow decorator<br/>remote=True
participant RunningContext
participant remote_forward_v0
participant RemoteService as Target Service<br/>/invoke endpoint
Decorator->>RunningContext: invoke() with remote flag
RunningContext->>RunningContext: select remote_forward_v0 handler
RunningContext->>remote_forward_v0: execute with request/parameters/inputs
remote_forward_v0->>remote_forward_v0: extract revision URL/headers
remote_forward_v0->>RemoteService: POST /invoke with payload + forwarded headers
RemoteService-->>remote_forward_v0: response
remote_forward_v0-->>RunningContext: return response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR extends the playground workflow configuration pipeline to handle all workflow.data.* fields (not just data.parameters), enabling full editing/diffing/committing of custom hook (url, headers) and code (script, runtime) workflow settings.
Changes:
- Add dedicated hook/code UI controls and surface them as top-level config sections in the playground (including a runtime picker for code workflows).
- Update dirty detection, diff/commit context, draft patching, and commit payloads to operate on the full
dataobject. - Tighten types by reusing
WorkflowDatain API payloads and constrainingruntimeto an enum.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/index.ts | Exports the new dedicated hook/code config control. |
| web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/HookCodeConfigControl.tsx | Adds purpose-built UI for hook (URL/headers) and code (script) fields. |
| web/packages/agenta-entity-ui/src/DrillInView/components/PlaygroundConfigSection.tsx | Plumbs sibling data.* fields into the config UI, sections, and update routing. |
| web/packages/agenta-entity-ui/src/adapters/variantAdapters.ts | Builds commit/diff context from full data (with normalized parameters). |
| web/packages/agenta-entities/src/workflow/state/store.ts | Updates dirty detection to compare the full data object. |
| web/packages/agenta-entities/src/workflow/state/commit.ts | Sends explicit canonical WorkflowData fields (incl. headers/script/runtime) in commits. |
| web/packages/agenta-entities/src/workflow/snapshotAdapter.ts | Changes draft patching from {parameters}-only to shallow diff over full data. |
| web/packages/agenta-entities/src/workflow/core/schema.ts | Constrains runtime to `python |
| web/packages/agenta-entities/src/workflow/api/api.ts | Reuses WorkflowData for create/update payload typing. |
| web/AGENTS.md | Adds a “keep in-code comments terse” guideline. |
Comments suppressed due to low confidence (1)
web/packages/agenta-entity-ui/src/DrillInView/components/PlaygroundConfigSection.tsx:1687
- The loading/empty-state gating only checks
hasParameters(activeData), so hook/code workflows with no parameters but with sibling groups (code/hook) will incorrectly show “No configuration needed” and never render the new accordions.
[collapsedSections, parameters, siblingGroups, disabled, promptModelInfo?.isRootLevel],
)
// ========== LOADING / EMPTY STATE ==========
const isConfigLoading = schemaQuery.isPending && !hasParameters(activeData)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d91a54e7-a9d5-4518-a673-3b05b27f2676
📒 Files selected for processing (10)
web/AGENTS.mdweb/packages/agenta-entities/src/workflow/api/api.tsweb/packages/agenta-entities/src/workflow/core/schema.tsweb/packages/agenta-entities/src/workflow/snapshotAdapter.tsweb/packages/agenta-entities/src/workflow/state/commit.tsweb/packages/agenta-entities/src/workflow/state/store.tsweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/HookCodeConfigControl.tsxweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/index.tsweb/packages/agenta-entity-ui/src/DrillInView/components/PlaygroundConfigSection.tsxweb/packages/agenta-entity-ui/src/adapters/variantAdapters.ts
Railway Preview Environment
|
4cf6682 to
8123899
Compare
381865e to
c5ad34d
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (4)
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/HookConfigControl.tsx (1)
1-6: ⚡ Quick winTrim multi-line comment blocks to the one-line comment rule.
These newly added doc comments are multi-line blocks; this repo rule requires comments to be at most one short line.
As per coding guidelines: “Keep in-code comments to at most ONE short line per comment. Do not write multi-line blocks narrating why in prose or restating what the code shows.”
Also applies to: 103-106, 111-112
Source: Coding guidelines
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/CodeConfigControl.tsx (1)
1-6: ⚡ Quick winReduce new multi-line comments to single-line comments.
Several added comment blocks exceed the repo’s one-line comment limit.
As per coding guidelines: “Keep in-code comments to at most ONE short line per comment. Do not write multi-line blocks narrating why in prose or restating what the code shows.”
Also applies to: 19-20, 95-98, 103-104
Source: Coding guidelines
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/SchemasConfigControl.tsx (1)
1-8: ⚡ Quick winConform added comment blocks to the one-line comment guideline.
The new comments are multi-line prose blocks; this codebase requires single short-line comments only.
As per coding guidelines: “Keep in-code comments to at most ONE short line per comment. Do not write multi-line blocks narrating why in prose or restating what the code shows.”
Also applies to: 126-129
Source: Coding guidelines
web/packages/agenta-entity-ui/src/DrillInView/components/PlaygroundConfigSection.tsx (1)
303-304: ⚡ Quick winPlease collapse newly added multi-line prose comments to single-line comments.
These new comment blocks exceed the one-line comment policy for TS/TSX files.
As per coding guidelines: “Keep in-code comments to at most ONE short line per comment. Do not write multi-line blocks narrating why in prose or restating what the code shows.”
Also applies to: 325-326, 360-361, 473-475, 500-501
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 705e0336-4430-4c47-8853-6fdd497b6318
📒 Files selected for processing (13)
web/AGENTS.mdweb/packages/agenta-entities/src/workflow/api/api.tsweb/packages/agenta-entities/src/workflow/core/schema.tsweb/packages/agenta-entities/src/workflow/snapshotAdapter.tsweb/packages/agenta-entities/src/workflow/state/commit.tsweb/packages/agenta-entities/src/workflow/state/runnableSetup.tsweb/packages/agenta-entities/src/workflow/state/store.tsweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/CodeConfigControl.tsxweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/HookConfigControl.tsxweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/SchemasConfigControl.tsxweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/index.tsweb/packages/agenta-entity-ui/src/DrillInView/components/PlaygroundConfigSection.tsxweb/packages/agenta-entity-ui/src/adapters/variantAdapters.ts
✅ Files skipped from review due to trivial changes (2)
- web/AGENTS.md
- web/packages/agenta-entities/src/workflow/api/api.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- web/packages/agenta-entities/src/workflow/core/schema.ts
- web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/index.ts
- web/packages/agenta-entities/src/workflow/state/commit.ts
- web/packages/agenta-entities/src/workflow/state/runnableSetup.ts
- web/packages/agenta-entities/src/workflow/state/store.ts
- web/packages/agenta-entity-ui/src/adapters/variantAdapters.ts
- web/packages/agenta-entities/src/workflow/snapshotAdapter.ts
code and hook workflowscode and hook workflows and their schemas
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c818e5bf-ee21-45d8-926e-175eefeaa86d
📒 Files selected for processing (4)
sdks/python/agenta/sdk/decorators/running.pysdks/python/agenta/sdk/engines/running/errors.pysdks/python/agenta/sdk/engines/running/handlers.pysdks/python/agenta/sdk/middlewares/running/resolver.py
…ok config) Generalize the playground config pipeline from data.parameters-only to the whole data object, so code (script/runtime) and hook (url/headers) workflow fields are rendered, diffed, and committed. Covers all five layers: render, dirty detection, patch build, diff preview, and commit payload. Sibling sections are uri-gated (custom:hook -> url/headers, custom:code -> script/runtime). Reuses the canonical WorkflowData type and aligns runtime to the backend enum. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render the code/hook data fields as one grouped 'Code'/'Hook' accordion via a dedicated HookCodeConfigControl (no synthetic schema): hook shows a URL input + key/value Headers editor; code shows a script editor with tool-card chrome (copy, collapse, line numbers) whose language follows the runtime, plus a runtime picker in the section header styled like the model picker. Sections match the prompt accordion (full-bleed header, spaced from params). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The playground app-workflow invoke payload sent data.{inputs,parameters} only.
hook_v0 resolves the webhook url/headers from data.revision (a full
WorkflowRevision), so without it the call had no url to forward to. Forward the
whole revision under data.revision.
01bb436 to
5e121f3
Compare
- New Schemas section (parameters/inputs/outputs JSON-schema editors) shown for
both hook and code workflows, sourced from data.schemas. Section and each
field collapsed by default; tool-card chrome (copy/collapse/line numbers).
Writes route under data.schemas via {__siblingData:{schemas:...}}.
- Split HookCodeConfigControl into dedicated HookConfigControl and
CodeConfigControl (one component per kind), consistent with SchemasConfigControl.
A workflow declaring uri=*:custom:hook:* used to resolve to the managed hook_v0
forwarder, which posted to the revision url verbatim. When the workflow IS the
url's target, that meant it never ran its own handler and called itself.
- @ag.workflow gains remote: bool = False. remote=True forwards to {url}/invoke
(new remote_forward_v0, which also rstrips and appends /invoke, and forwards
headers); remote=False runs the installed handler in-process.
- A custom-hook URI no longer binds a managed handler, so the decorator's own
handler runs. The resolver keeps a handler the decorator already installed.
- hook_v0 is now a raising stub (CustomHookHandlerNotDefinedV0Error); reaching
it means a custom hook had no handler and no remote.
5e121f3 to
669ef4c
Compare
Code reviewFound 2 issues, both in the
agenta/web/packages/agenta-entities/src/workflow/state/store.ts Lines 1825 to 1839 in 669ef4c
agenta/web/packages/agenta-entities/src/workflow/state/store.ts Lines 1739 to 1742 in 669ef4c 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
The whole-data dirty check compared server schemas.parameters (flat for evaluators) against the nested entity schema, so every evaluator workflow reported dirty on load. Nest the server schema to match. Fix stale comment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Migrate hook forwarding tests to remote_forward_v0 (forwarding moved off hook_v0, now a raising stub); add a stub-raises test. - Coerce forwarded webhook headers to str->str for httpx. - Neutral wording for the custom-hook-not-defined error. - mergeSiblingFields: default runtime to python (no false 'Select runtime'). - getChangesFromPath: emit tagged __siblingData for sibling paths. - URL placeholder drops /invoke (always appended by remote_forward_v0). - Condense multi-line comments per AGENTS.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
setValueAtPath is immutable; the sibling/param branches ignored its return value and emitted the pre-update object. Use the returned value. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Context
Code and hook workflows carry settings that lives outside
data.parameters: code workflows have ascriptandruntime, hook workflows have aurlandheaders. These sit as siblings ofparametersinside the revision'sdataobject. The playground never rendered them, and the whole config pipeline only ever looked atdata.parameters, so even if they had rendered, edits would not have been detected as dirty, diffed, or committed.Changes
1. All-data plumbing. The config pipeline now covers every
data.*field, not justparameters, across the five layers it touches:PlaygroundConfigSection.tsxsurfaces the sibling fields, gated by the workflow URI so they only show for custom hook/code workflows.store.tscompares the wholedataobject with a deep equal (parameters stay normalized to avoid false positives) instead of only diffing parameters.snapshotAdapter.tsshallow-diffs the wholedata(parameters nested), so any sibling field change produces a patch.variantAdapters.tsbuilds the commit context from the wholedataon both sides.commit.tssends every canonical field. The backend model isextra="forbid", so the payload explicitly picksuri,url,headers,script,runtime,parameters,schemasrather than spreading.api.tsreuses the canonicalWorkflowDatatype instead of an inline shape, andschema.tsadds theruntimeenum (python | typescript | javascript).Before, a patch was always
data: {parameters}. After, it is a diff over the fulldataobject.2. Code/Hook UX. A grouped accordion renders the sibling fields through a dedicated
HookCodeConfigControl(no synthetic schema):The accordion matches the existing Prompt accordion (full-bleed header, spacing before it when there are parameters above).
Tests / notes
datain Postgres (workflow_revisions).What to QA